/* Copyright (C) 2012  Chris Mueller <ruunsmail@googlemail.com>
 *
 * This file is part of the Liquid Programming Language
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIQUID__PARSER_H
#define LIQUID__PARSER_H

#include "base.h"
#include "scanner.h"

struct LqNode;
struct LqParser;

struct LqNode*          lq_parse(struct LqContext* context);

void                    lq_parse_eat(struct LqContext* context, enum LqTOK value, const gchar* error);
int                	    lq_parse_eat_if(struct LqContext* context, enum LqTOK value);
struct LqToken		    lq_parse_next(struct LqContext* context);
int			            lq_parse_is_next(struct LqContext* context, enum LqTOK value, size_t index);
int			            lq_parse_is_next_on_line(struct LqContext* context, enum LqTOK value);
int			            lq_parse_is_next_expr(struct LqContext* context);
int			            lq_parse_is_next_pattern(struct LqContext* context);

void                    lq_parse_enter_scope(struct LqContext* context, struct LqNode* node);
void			        lq_parse_leave_scope(struct LqContext* context);

struct LqNode*          lq_parse_toplevel(struct LqContext* context);
struct LqNode*		    lq_parse_module(struct LqContext* context);

struct LqNode*		    lq_parse_expr(struct LqContext* context);
struct LqNode*		    lq_parse_block_expr(struct LqContext* context);
struct LqNode*          lq_parse_logical_or_expr(struct LqContext* context);
struct LqNode*          lq_parse_logical_and_expr(struct LqContext* context);
struct LqNode*          lq_parse_equality_expr(struct LqContext* context);
struct LqNode*          lq_parse_relational_expr(struct LqContext* context);
struct LqNode*          lq_parse_list_operation_expr(struct LqContext* context);
struct LqNode*          lq_parse_bitwise_or_expr(struct LqContext* context);
struct LqNode*          lq_parse_bitwise_xor_expr(struct LqContext* context);
struct LqNode*          lq_parse_bitwise_and_expr(struct LqContext* context);
struct LqNode*          lq_parse_shift_expr(struct LqContext* context);
struct LqNode*          lq_parse_additive_expr(struct LqContext* context);
struct LqNode*          lq_parse_multiplicative_expr(struct LqContext* context);
struct LqNode*          lq_parse_power_expr(struct LqContext* context);
struct LqNode*          lq_parse_unary_expr(struct LqContext* context);
struct LqNode*          lq_parse_field_access_expr(struct LqContext* context);
struct LqNode*          lq_parse_primary_expr(struct LqContext* context);
struct LqNode*          lq_parse_scoping_expr(struct LqContext* context);
struct LqNode*          lq_parse_valuecall_expr(struct LqContext* context);
struct LqNode*          lq_parse_constant_expr(struct LqContext* context);
struct LqNode*          lq_parse_tuple_expr(struct LqContext* context);
struct LqNode*		    lq_parse_list_expr(struct LqContext* context);
struct LqNode*		    lq_parse_list_generator_expr(struct LqContext* context);
struct LqNode*		    lq_parse_fun_expr(struct LqContext* context);
struct LqNode*          lq_parse_if_expr(struct LqContext* context);
struct LqNode*          lq_parse_match_expr(struct LqContext* context);

struct LqNode*		    lq_parse_pattern_expr(struct LqContext* context);
struct LqNode*		    lq_parse_base_pattern_expr(struct LqContext* context);
struct LqNode*		    lq_parse_tuple_pattern_expr(struct LqContext* context);
struct LqNode*		    lq_parse_list_pattern_expr(struct LqContext* context);
struct LqNode*          lq_parse_cons_pattern_expr(struct LqContext* context);
struct LqNode*	        lq_parse_constant_pattern_expr(struct LqContext* context);
struct LqNode*	        lq_parse_assignment_pattern_expr(struct LqContext* context);
struct LqNode*	        lq_parse_let_pattern_expr(struct LqContext* context);

#endif // LIQUID__PARSER_H
